package com.ilancuo.thinkinjava.chapter_06;

import java.util.Arrays;

public class Range {

    //[0, n)
    public static int[] range(int n) {
        int[] result = new int[n];
        for (int i = 0; i < n; i++) {
            result[i] = i;
        }
        return result;
    }

    // [start, end)
    public static int[] range(int start, int end) {
        int sz = end - start;
        int[] result = new int[sz];
        for (int i = 0; i < sz; i++) {
            result[i] = i + start;
        }
        return result;
    }

    // [start, end, step)
    public static int[] range(int start, int end, int step) {
        int sz = (end - start) / step + 1;
        int[] result = new int[sz];
        for (int i = 0; i < sz; i++) {
            result[i] = start + (i * step);
        }
        return result;
    }

    public static void main(String[] args) {
        System.out.println(Arrays.toString(range(2, 12, 3)));
    }
}
